package com.hbnu.commonclass;

/**
 * @author kittychen
 * @date 2025-09-23 下午 3:24
 */
public class StringTest {

    public static void main(String[] args) {
        String str = "abc";
        String str2 = new String("abc");
        System.out.println(str == str2);   // false
        System.out.println(str.equals(str2));  // true
        String str3 = "abc";
        System.out.println(str == str3);   // true

        String content = " Learning English is like. building a house. Laying a strong foundation " +
                "is the first and most important step. ";
        System.out.println(content.length());
        System.out.println(content.indexOf('a'));
        System.out.println(content.lastIndexOf('a'));
        System.out.println(content.substring(3));  // 截取
        System.out.println(content.substring(3, 10));   // 包含开始位置，不包含结束位置

        System.out.println("========================");
        System.out.println(content.trim());
        System.out.println(content.toUpperCase());
        String[] split = content.split("\\.");  // 切割字符串
        for (String s : split) {
            System.out.println(s);
        }

    }
}
